
def linearSearch(li,element):
    size = len(li)

    for i in range(0,size):
        if li[i] == element:
            return True

    return False


# list has to be sorted
def binarySearch(li,element):
    start = 0
    end = len(li)-1
    while start < end:
        mid = (start+end)/2
        if li[mid] == element:
            return True
        elif li[mid] > element:
            start = mid+1
            end = len(li)-1
        else:
            start = 0
            end = mid-1

    return False


li = [1,2,3,4,5,6]

print binarySearch(li,3)
print linearSearch(li,3)